package com.cat.mrli.rat.programs;

import android.content.Context;
import android.opengl.GLES20;

import com.cat.mrli.rat.util.ShaderHelper;
import com.cat.mrli.rat.util.TextResourceReader;

/**
 * Created by mrli on 2017/6/25.
 */

public class ShaderProgram {

    protected static final String U_MATRIX = "u_Matrix";
    protected static final String U_TEXTURE_UNIT_TABLE = "u_TextureUnit_Table";
    protected static final String U_TEXTURE_UNIT_ICON = "u_TextureUnit_Icon";
    protected static final String A_TEXTURE_COORDINATES = "a_TextureCoordinates";
    protected static final String A_POSITION = "a_Position";
    protected static final String A_COLOR = "a_Color";
    protected static final String U_COLOR = "u_Color";

    protected final int program;

    public ShaderProgram(Context context, int vertexShaderResourceID,
                         int fragmentShaderResourceId) {
        this.program = ShaderHelper.buildProgram(
                TextResourceReader.readTextFiledFormResource(context, vertexShaderResourceID),
                TextResourceReader.readTextFiledFormResource(context, fragmentShaderResourceId));
    }


    public void userProgram() {
        GLES20.glUseProgram(program);
    }

}
